// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name:   SecurityTools.java

package com.haoxi.gateway.test.util;

import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
//import javax.


public class SecurityTools
{

    private static final byte salt[] = "webplat".getBytes();

    public SecurityTools()
    {
    }

    public static String digest(String str)
    {
        try
        {
            MessageDigest md5 = MessageDigest.getInstance("SHA");
            md5.update(salt);
            String s = Base64.encode(md5.digest(str.getBytes()));
            return s;
        }
        catch(NoSuchAlgorithmException ex)
        {
            throw new UnsupportedOperationException(ex.toString());
        }
    }

    public static void md5(byte data[], int offset, int length, byte digest[], int dOffset)
    {
        try
        {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(data, offset, length);
            md5.digest(digest, dOffset, 16);
        }
        catch(NoSuchAlgorithmException ex)
        {
            ex.printStackTrace();
        }
        catch(DigestException ex)
        {
            ex.printStackTrace();
        }
    }

    public static byte[] md5(byte data[], int offset, int length)
    {
        try
        {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(data, offset, length);
            byte abyte0[] = md5.digest();
            return abyte0;
        }
        catch(NoSuchAlgorithmException ex)
        {
            ex.printStackTrace();
        }
        byte abyte1[] = null;
        return abyte1;
    }
}
